


***********************************************
****** The Impact of Soft-Skills Training *****
******    for Entrepreneurs in Jamaica    *****
***********************************************


* This file prepares the data coming from the questionnaire for follow-up 2, to use for the analysis


clear all
cap log close
set more off

cap cd "$directory"



************
*** Data ***
************

*** Load follow-up 2 data ***

* Load questionnaire data
use "$data_int/fu2_data_cleaned", clear

* Keep only completed interviews
keep if d1q2==1


*** Merge with other data ***

* Merge with data from the respondent log (sensitizers' calls)
merge 1:1 respondent_id using "$data_int/fu2_sensitizing_data", gen(merge_sensitizing)
lab var merge_sensitizing "Merge with sensitizing data"
lab def merge_sensit 1 "Questionnaire only" 2 "Sensitizers data only" 3 "Questionn. and sensit. data"
lab val merge_sensitizing merge_sensit

* Merge with data on goal quality (assessed by Daniel)
merge 1:1 respondent_id using "$data_int/fu2_goals", assert(master match) nogen

* Merge with treatment assignment
merge 1:1 respondent_id using "$data_int/treatment_assignment", assert(match using) keep(match) nogen
order treatment t1 t2 strata, after(respondent_id)


*** Define and assign labels ***

lab def yn 0 "No" 1 "Yes", modify
lab def yn_survey 1 "Yes" 2 "No"
lab val m1q7 m1q11 m2q1 m2q2 m2q6 m2q11_a m2q12 m2q18 m2q21_a_3 m2q21_c_3 m2q24_* m2q25 m2q26 m2q27 ///
	m2q32 m2q41 m2q44_a_? m2q44_b_? m2q45 m2q47 m2q49 m2q50 m3q1_d m3q2_d i_?_m3q3_e ///
	m6q2 i_?_m6q3 m6q6 i_?_m6q7 m7q6 m8q1 m8q4 yn_survey

lab def dk .a "Don't know" .b "Don't want to answer" .c "Not applicable"

lab def visit_result ///
	1 "Respondent found and available for the interview" ///
	2 "Respondent asks to come back later" ///
	3 "Could not find the respondent" ///
	4 "Respondent refuses" ///
	5 "Other"
lab val d1q2 visit_result

lab def interview_location ///
	1 "Respondent's home" ///
	2 "Respondent's business" ///
	3 "D&N office" ///
	4 "Other"
lab val m1q1 interview_location

lab def interviewed_w1 1 "Yes" 2 "No" 3 "Don't know"
lab val m1q2 interviewed_w1

lab def own_business 1 "Still own business" 2 "Recently closed business" 3 "Don't own a business"
lab val m1q9 own_business

lab def reason_nomorebusiness ///
	1 "Wanted to invest in a new company instead" ///
	2 "Found a salaried job opportunity" ///
	3 "Had family obligations (child, sick relative, death in the family, etc.)" ///
	4 "Moved" ///
	5 "Retired" ///
	6 "Sold the company" ///
	7 "Passed the company on to a family member" ///
	8 "Was sick" ///
	9 "Travelled" ///
	94 "Other"
lab val m2q3 reason_nomorebusiness

lab def current_employment ///
	1 "Paid employee in the public sector" ///
	2 "Paid employee in the private sector" ///
	3 "Head of a company" ///
	4 "Unpaid worker in a family business" ///
	5 "Unpaid worker on a family farm" ///
	6 "Unpaid worker in another company" ///
	7 "Not working, searching for a salaried position" ///
	8 "Not working, not looking for work" ///
	9 "Temporary or seasonal worker" ///
	10 "Student, apprentice" ///
	11 "Retired" ///
	94 "Other"
lab val m2q4_a current_employment

lab def sector ///
	1 "Manufacturing" /// 
	2 "Trade/Retail (purchase and sale of merchandise)" /// 
	3 "Food preparation/Restaurants" /// 
	4 "Hotels" ///
	5 "Hair and beauty care" /// 
	6 "Repair and/or construction" /// 
	7 "IT and computer services" /// 
	8 "Other services" /// 
	9 "Agriculture/Forestry" /// 
	94 "Other"
lab val m2q7_a m2q7_c m2q7_e sector

lab def days_open 8 "Business is not in activity or is never open"
lab val m2q8 days_open

lab def months_goal .a "Don't know" -1 "Don't know" 0 "Goal already achieved" 1 "1 month or less"
lab val m2q11_c m2q11_d months_goal

lab def freq_evaluation ///
	1 "Never" /// 
	2 "Less than once a month" ///
	3 "About once a month" ///
	4 "About twice a month" ///
	5 "About once a week" ///
	6 "Every day" ///
	7 "I did not have employees in the last 6 months"
lab val m2q15 m2q16 freq_evaluation

lab def made_profits ///
	1 "Loss" ///
	2 "Profit" ///
	3 "Break even"
lab val m2q21_a_1 m2q21_b_1 m2q21_c_1 made_profits

lab def months ///
	1 "January" ///
	2 "February" ///
	3 "March" ///
	4 "April" ///
	5 "May" ///
	6 "June" ///
	7 "July" ///
	8 "August" ///
	9 "September" ///
	10 "October" ///
	11 "November" ///
	12 "December" ///
	99 "Don't know" ///
	.a "Don't know"
lab val m2q21_c_5 m7q2_a months

lab def entrepreneurs_met ///
	1 "None" ///
	2 "One" ///
	3 "Two to five" ///
	4 "Six to ten" ///
	5 "More than ten"
lab val m2q28 entrepreneurs_met

lab def new_prodsvc ///
	1 "Yes, a new product" /// 
	2 "Yes, a new service" /// 
	3 "Yes, both a new product and a new service" /// 
	4 "No" ///
	99 "Don't know"
lab val m2q29 new_prodsvc

lab def new_prodsvc_invented ///
	1 "Invented by the company based on its own ideas" /// 
	2 "Invented by the company, but inspired by ideas seen elsewhere" /// 
	3 "Purchased from a supplier" /// 
	94 "Other"
lab val m2q31 new_prodsvc_invented

lab def implementation ///
	1 "No" /// 
	2 "Yes, by myself" /// 
	3 "Yes, by others"
lab val m2q36 m2q38 m2q40 implementation

lab def investment_source ///
	1 "My own savings" ///
	2 "Loan from formal institution (bank, microfinance)" ///
	3 "Informal loan or gift from family/friends" ///
	4 "Informal loan from moneylender" ///
	5 "Informal loan/contribution from your business partner" ///
	6 "Reinvestment of firm’s profits" ///
	94 "Other"
lab val m2q42_o? investment_source

lab def game_difficulty 0 "Easy" 1 "Difficult"
lab def game1_difficulty_survey 1 "Easy" 2 "Difficult" 98 "None" 99 "Don't know"
lab val m3q0 i_1_m3q3_a i_2_m3q3_a i_3_m3q3_a i_4_m3q3_a m3q4_a game1_difficulty_survey

lab def game_correct 1 "Correct answer" 0 "Wrong answer" .b "Don't want to answer"
lab def game_correct_survey 1 "Correct answer" 2 "Wrong answer" 3 "Don't want to answer"
lab val m3q1_c m3q2_c i_1_m3q3_d i_2_m3q3_d i_3_m3q3_d i_4_m3q3_d m5q6 game_correct_survey

lab def game1_completed 1 "Respondent completed all rounds of game 1" 2 "Respondent didn't complete all rounds of game 1"
lab val m3q3_f game1_completed

lab def decision_maker ///
	1 "Myself" ///
	2 "My spouse/ partner" ///
	3 "Me and my spouse/ partner" ///
	4 "Others" ///
	5 "Me and others" ///
	6 "None" ///
	99 "Don't want to answer" ///
	.b "Don't want to answer"
lab val m4q5_* decision_maker

lab def game2_difficulty_survey 1 "On own" 2 "Assisted"
lab val m5q1_a m5q1_b game2_difficulty_survey

lab def likert_1 ///
	1 "Strongly disagree" ///
	2 "Disagree" ///
	3 "Neither nor" ///
	4 "Agree" ///
	5 "Strongly agree"
lab val m6q9_* m6q10_* m6q12_* m6q13_* likert_1

lab def likert_2 ///
	1 "Strongly disagree" ///
	2 "Disagree" ///
	3 "Somewhat disagree" ///
	4 "Neither agree nor disagree" ///
	5 "Somewhat agree" /// 
	6 "Agree" ///
	7 "Strongly Agree"
lab val m6q14_* likert_2

lab def course_skills ///
	1 "Accounting or financial management" /// 
	2 "Marketing or customer relations" /// 
	3 "Administration, purchasing, or logistics" /// 
	4 "Negotiation" /// 
	5 "Initiative or personal motivation" /// 
	6 "Strategy or identifying business opportunities" /// 
	7 "Drafting a business plan / searching for financing" /// 
	8 "Succeeding in a market or in your industry" /// 
	9 "Setting goals" /// 
	10 "Innovation" /// 
	11 "Production techniques" /// 
	94 "Other"
lab val m7q3_o? m7q3_o?? course_skills

lab def course_hours ///
	1 "Between 1 and 5 hours" ///
	2 "Between 6 and 10 hours" ///
	3 "Between 11 and 20 hours" ///
	4 "Between 21 and 30 hours" ///
	5 "Between 31 and 40 hours" ///
	6 "More than 40 hours"
lab val m7q4 course_hours

lab def likert_3 ///
	1 "Strongly Disagree" ///
	2 "Somewhat Disagree" ///
	3 "Neither Agree nor Disagree" ///
	4 "Somewhat Agree" ///
	5 "Strongly Agree"
lab val m7q5 likert_3

lab def interview_conditions ///
	1 "Not at all" ///
	2 "Not really" ///
	3 "During a part of the interview" ///
	4 "Throughout the interview"
lab val m8q6_? interview_conditions



************************
*** SYSTEM VARIABLES ***
************************

*** Syst. vars: label old variables ***

* Date
lab var date "Date of the interview"


*** Syst. vars: convert hours to format %tc ***

rename duration duration_string
gen duration=clock(duration_string,"#hms")
lab var duration "Interview duration"
format duration %tc
order duration, after(duration_string)


*** Syst. vars: generate new variables ***

* Generate datetime variables
gen date_interview=dofc(date)
gen date_upload=dofc(upload)
lab var date_interview "Date of interview"
lab var date_upload "Date of upload"
format date_interview date_upload %tdDD/NN/CCYY

* Record month of the interview
gen month_interview=month(date_interview)
lab var month_interview "Month of interview"
lab val month_interview months



****************
*** MODULE 1 ***
****************

*** Mod. 1: generate new variables ***

* Self-employment
gen selfemp=(m1q9==1|m2q1==1) if !missing(m1q9) | !missing(m2q1)
lab var selfemp "Self employed"
lab val selfemp yn

* Firm survival (which accounts also for data for attriters, from sensitizers calls)
gen has_business=selfemp
replace has_business=selfemp_attrit if missing(selfemp)
lab var has_business "Owns a business"
lab val has_business yn


****************
*** MODULE 2 ***
****************

*** Mod. 2: edit existing variables ***

* Personal income
clonevar income_lastmonth=m2q4_b_best
lab var income_lastmonth "Income in the last month"

* Registration with Companies Office of Jamaica
recode m2q6 (2 = 0), gen(register_bus)
replace register_bus=0 if selfemp==0
lab var register_bus "Registered business"
lab val register_bus yn

* Goal setting and timeline
recode m2q11_a (2 = 0), gen(set_goal)
replace set_goal=0 if selfemp==0
lab var set_goal "Set a goal for business"
lab val set_goal yn
clonevar goal_setdate=m2q11_c
lab var goal_setdate "Months ago goal was set"
recode m2q11_d (-1 = .a), gen(goal_achievedate)
lab var goal_achievedate "Months from now goal will be achieved"
lab val goal_achievedate months_goal

* Goal quality (from Daniel's assessment)
replace goal_quality=0 if set_goal==0
replace goal_quality=0 if selfemp==0
lab var goal_quality "Goal quality"

* Employees
recode m2q12 (2 = 0), gen(has_employees)
lab var has_employees "Has employees"
lab val has_employees yn

* Amount of costs
recode m2q17_* (-1 = .a), gen(costs_lastm costs_inputs costs_utilities costs_salaries costs_loans costs_phone_internet ///
	costs_maintenance costs_transport costs_rentequip costs_rentestate costs_mktsite costs_incidentals costs_other)
foreach var of varlist costs_lastm costs_inputs costs_utilities costs_salaries costs_loans costs_phone_internet ///
		costs_maintenance costs_transport costs_rentequip costs_rentestate costs_mktsite costs_incidentals costs_other {
	replace `var'=0 if selfemp==0
	}
lab var costs_lastm "Total costs in the last month"
lab var costs_inputs "Costs: inputs"
lab var costs_utilities "Costs: electricity, gas, water"
lab var costs_salaries "Costs: salaries and allowances"
lab var costs_loans "Costs: loan payments"
lab var costs_phone_internet "Costs: telephone and internet"
lab var costs_maintenance "Costs: maintenance"
lab var costs_transport "Costs: transportation"
lab var costs_rentequip "Costs: rental of equipment"
lab var costs_rentestate "Costs: rental of estate, buildings and land"
lab var costs_mktsite "Costs: market sites"
lab var costs_incidentals "Costs: incidentals or gifts"
lab var costs_other "Costs: other"
lab val costs_lastm costs* dk

* Amount of sales
recode m2q19_a_best m2q19_b_best (-1 = .a), gen(sales_lastm sales_lastw)
replace sales_lastm=0 if m2q18==2
replace sales_lastw=0 if m2q18==2
replace sales_lastm=m1q10_a_best if m1q7==2 & m1q10_a_best!=-1
replace sales_lastm=.a if m1q7==2 & m1q10_a_best==-1
lab var sales_lastm "Sales in the last month"
lab var sales_lastw "Sales in the last week"
foreach var of varlist sales_lastm sales_lastw {
	replace `var'=0 if selfemp==0
}
lab val sales_* dk

* Profit/loss/break-even
clonevar made_profits_lastm=m2q21_a_1
clonevar made_profits_lastw=m2q21_b_1
clonevar made_profits_bestm=m2q21_c_1
lab var made_profits_lastm "Made profits in the last month"
lab var made_profits_lastw "Made profits in the last week"
lab var made_profits_bestm "Made profits in the best month"
lab val made_profits_* made_profits

* Amount of profits
recode m2q21_a_2_best m2q21_b_2_best m2q21_c_2_best (-1 = .a), gen(profits_lastm profits_lastw profits_bestm)
replace profits_lastm=0 if m2q21_a_1==3
replace profits_lastw=0 if m2q21_b_1==3
replace profits_bestm=0 if m2q21_c_1==3
replace profits_lastm=-m2q21_a_2_best if m2q21_a_1==1 & !missing(profits_lastm)
replace profits_lastw=-m2q21_b_2_best if m2q21_b_1==1 & !missing(profits_lastw)
replace profits_bestm=-m2q21_c_2_best if m2q21_c_1==1 & !missing(profits_bestm)
replace profits_lastm=0 if m1q10_b_1==3
replace profits_lastm=-m1q10_b_2_best if m1q10_b_1==1 & !missing(m1q10_b_2_best)
foreach var of varlist profits_lastm profits_lastw profits_bestm {
	replace `var'=0 if selfemp==0
}
lab var profits_lastm "Profits in the last month"
lab var profits_lastw "Profits in the last week"
lab var profits_bestm "Profits in the best month"
lab val profits* dk

*Other business
clonevar other_business=m2q22
replace other_business=0 if m2q22==1
replace other_business=1 if m2q22==2
replace other_business=0 if selfemp==0

* Amount of other profits
recode m2q23_b_best  (-1 = .a), gen(othprofits_lastm)
replace othprofits_lastm=0 if m2q23_a==3
replace othprofits_lastm=-m2q23_b_best if m2q23_a==1 & !missing(othprofits_lastm)
replace othprofits_lastm=0 if other_business==0
lab var othprofits_lastm "Profits in the last month from other businesses"
egen totalprofits_lastm=rowtotal(othprofits_lastm profits_lastm), mis
lab var totalprofits_lastm "Tot. profits for all businesses in the last month"

* Business practices
recode m2q24_* (2 = 0), prefix(busprac_)
forvalues i=1/25 {
	rename busprac_m2q24_`i' busprac_`i'
	lab var busprac_`i' "Business practice `i'"
}
lab val busprac_* yn
gen rev_busprac_10=1-busprac_10
lab var rev_busprac_10 "Business practice 10 (reversed)"

* Networking
recode m2q26 m2q27 (2 = 0), gen(purchased_bulk shared_inputs)
replace purchased_bulk=0 if selfemp==0
replace shared_inputs=0 if selfemp==0
lab var purchased_bulk "Purchased inputs/stock in bulk with others"
lab var shared_inputs "Shared inputs, tools, equipment, or employees with others"
lab val purchased_bulk shared_inputs yn

* New products/services
recode m2q29 (1 2 3 = 1 "Yes") (4 = 0 "No") (99 = .a "Do not know"), gen(new_prod_svc)
replace new_prod_svc=0 if m2q30==1
clonevar total_new_prod_svc=m2q30_other
replace total_new_prod_svc=0 if new_prod_svc==0
gen new_prod_svc_invented=(m2q31==1) if !mi(m2q31)
replace new_prod_svc_invented=0 if new_prod_svc==0
recode m2q32 (2 = 0), gen(new_prod_svc_newtoregion)
replace new_prod_svc_newtoregion=0 if new_prod_svc==0
foreach var of varlist new_prod_svc total_new_prod_svc new_prod_svc_invented new_prod_svc_newtoregion {
	replace `var'=0 if selfemp==0
}
lab var new_prod_svc "Introduced new products/services"
lab var total_new_prod_svc "N. of new products/services"
lab var new_prod_svc_invented "New products/services were invented by company"
lab var new_prod_svc_newtoregion "New products/services were new to region"
lab val new_prod_svc new_prod_svc_invented new_prod_svc_newtoregion yn

* Business ideas
recode m2q33 m2q35 m2q37 m2q39 (1 = 0) (2 = 1), gen(has_ideas_business has_ideas_saving has_ideas_customerrel has_ideas_quality)
clonevar total_ideas_business=m2q33_other
replace total_ideas_business=0 if has_ideas_business==0
clonevar total_ideas_saving=m2q35_other
replace total_ideas_saving=0 if has_ideas_saving==0
clonevar total_ideas_customerrel=m2q37_other
replace total_ideas_customerrel=0 if has_ideas_customerrel==0
clonevar total_ideas_quality=m2q39_other
replace total_ideas_quality=0 if has_ideas_quality==0
clonevar impl_ideas_saving=m2q36
clonevar impl_ideas_customerrel=m2q38
clonevar impl_ideas_quality=m2q40
foreach var of varlist total_ideas_* has_ideas_* {
	replace `var'=0 if selfemp==0
}
lab var has_ideas_business "Had business ideas"
lab var total_ideas_business "N. of business ideas"
lab var has_ideas_saving "Had ideas to save"
lab var total_ideas_saving "N. of ideas to save"
lab var impl_ideas_saving "Implementation of ideas to save"
lab var has_ideas_customerrel "Had ideas for customer relationship"
lab var total_ideas_customerrel "N. of ideas for customer relationship"
lab var impl_ideas_customerrel "Implementation of ideas for customer relationship"
lab var has_ideas_quality "Had ideas for quality of products/services"
lab var total_ideas_quality "N. of ideas for quality of products/services"
lab var impl_ideas_quality "Implementation of ideas for quality of products/services"
lab val has_ideas_* yn

* Investments
recode m2q41 (2 = 0), gen(investment)
replace investment=0 if selfemp==0
clonevar investment_amount=m2q43
replace investment_amount=0 if investment==0
replace investment_amount=0 if selfemp==0
lab var investment "Made an investment"
lab var investment_amount "Amount of the investment"
lab val investment yn

* Assets
recode m2q46_* (-1 = .a), gen(assets_equip assets_othtools assets_vehicle assets_furniture assets_estate assets_other)
lab var assets_equip "Purchased assets: machines or equipment"
lab var assets_othtools "Purchased assets: other work tools"
lab var assets_vehicle "Purchased assets: vehicles"
lab var assets_furniture "Purchased assets: furniture"
lab var assets_estate "Purchased assets: land, buildings, facilities"
lab var assets_other "Purchased assets: other"

* Stock/inventory
recode m2q47 (2 = 0), gen(has_stock)
recode m2q48 (-1 = .a), gen(stock_value)
replace stock_value=0 if has_stock==0
replace has_stock=0 if selfemp==0
replace stock_value=0 if selfemp==0
lab var has_stock "Has stock"
lab var stock_value "Value of stock"
lab val stock_value dk


*** Mod. 2: generate new variables ***

* New activity (change/expansion to new sector)
gen new_activity=(m2q7_b==1 | m2q7_d==1) if !missing(m2q7_b,m2q7_d)
replace new_activity=0 if selfemp==0
lab var new_activity "Started new activity (change/expansion to new sector)"
lab val new_activity yn

* Business hours
gen business_hours=m2q8*m2q9
replace business_hours=0 if m2q8==8
replace business_hours=0 if selfemp==0
lab var business_hours "Business hours (per week)"

* Working hours
gen hours_worked=m2q10_a*m2q10_b
replace hours_worked=0 if selfemp==0
lab var hours_worked "Hours worked (per week)"

* Goal horizon
gen goal_horizon=goal_setdate+goal_achievedate
replace goal_horizon=0 if set_goal==0
replace goal_horizon=0 if selfemp==0
lab var goal_horizon "Goal horizon (months)"

* Employees
egen employees_fulltime=rowtotal(m2q13_a m2q14_a), missing
egen employees_parttime=rowtotal(m2q13_b m2q14_b), missing
gen total_employees=employees_fulltime+0.5*employees_parttime
gen employees_paid=m2q13_a+0.5*m2q13_b
gen employees_unpaid=m2q14_a+0.5*m2q14_b
foreach var of varlist employees_fulltime employees_parttime total_employees employees_paid employees_unpaid {
	replace `var'=0 if has_employees==0
	replace `var'=0 if selfemp==0
}
gen has_paid_employees=employees_paid>0 if !missing(employees_paid)
gen has_unpaid_employees=employees_unpaid>0 if !missing(employees_unpaid)
lab var employees_fulltime "N. of full-time employees"
lab var employees_parttime "N. of part-time employees"
lab var total_employees "N. of employees"
lab var employees_paid "N. of paid employees"
lab var employees_unpaid "N. of unpaid employees"
lab var has_paid_employees "Has paid employees"
lab var has_unpaid_employees "Has unpaid employees"
lab val has_paid_employees has_unpaid_employees yn

* Employees performance
gen emp_evaluation=(m2q15>=2 & m2q15<=6) if !missing(m2q15)
gen emp_feedback=(m2q16>=2 & m2q15<=6) if !missing(m2q16)
replace emp_evaluation=0 if selfemp==0
replace emp_feedback=0 if selfemp==0
lab var emp_evaluation "Evaluated employees performance at least once"
lab var emp_feedback "Gave feedback to employees at least once"

* Total business expenditures
egen sum_costs=rowtotal(costs_inputs-costs_other), missing
replace sum_costs=0 if selfemp==0
lab var sum_costs "Sum of expenditures"

* Corrected profits
clonevar corr_profits_lastm=profits_lastm
replace corr_profits_lastm=profits_lastm+m2q21_a_4 if m2q21_a_3==1 & m2q21_a_4!=-1 & !mi(profits_lastm)
replace corr_profits_lastm=0 if selfemp==0
clonevar corr_profits_bestm=profits_bestm
replace corr_profits_bestm=profits_bestm+m2q21_c_4 if m2q21_c_3==1 & m2q21_c_4!=-1 & !mi(profits_bestm)
replace corr_profits_bestm=0 if selfemp==0
lab var corr_profits_lastm "Profits in the last month (corr. for personal income)"
lab var corr_profits_bestm "Profits in the best month (corr. for personal income)"

* Positive profits dummies
gen pos_profits_lastm=(made_profits_lastm==2) if !missing(made_profits_lastm)
gen pos_profits_lastw=(made_profits_lastw==2) if !missing(made_profits_lastw)
gen pos_profits_bestm=(made_profits_bestm==2) if !missing(made_profits_bestm)
replace pos_profits_lastm=0 if selfemp==0
replace pos_profits_lastw=0 if selfemp==0
replace pos_profits_bestm=0 if selfemp==0
lab var pos_profits_lastm "Positive profits in the last month"
lab var pos_profits_lastw "Positive profits in the last week"
lab var pos_profits_bestm "Positive profits in the best month"
lab val pos_profits_lastm pos_profits_lastw pos_profits_bestm yn


* Networking
gen met_discuss_busideas=(m2q28!=1) if !missing(m2q28)
replace met_discuss_busideas=0 if selfemp==0
lab var met_discuss_busideas "Met entrepreneurs to discuss business ideas"
lab val met_discuss_busideas yn

* Loans
egen loan_requested=anymatch(m2q44_a_?), values(1)
egen loan_approved=anymatch(m2q44_b_?), values(1)
replace loan_requested=. if mi(m2q44_a_1,m2q44_a_2,m2q44_a_3,m2q44_a_4,m2q44_a_5,m2q44_a_6,m2q44_a_7)
replace loan_approved=. if mi(m2q44_a_1,m2q44_a_2,m2q44_a_3,m2q44_a_4,m2q44_a_5,m2q44_a_6,m2q44_a_7)
replace loan_requested=0 if selfemp==0
replace loan_approved=0 if selfemp==0
lab var loan_requested "Requested any loan"
lab var loan_approved "At least one loan approved"
lab val loan_requested loan_approved yn

* Total assets
egen sum_assets=rowtotal(assets_*), missing
replace sum_assets=0 if selfemp==0
lab var sum_assets "Sum of assets purchased"


****************
*** MODULE 3 ***
****************

*** Mod. 3: generate new variables ***

* Level of difficulty for rounds 1 and 2
gen g1_r1_difficult=0 if d1q2==1
gen g1_r2_difficult=1 if d1q2==1


*** Mod. 3: edit existing variables ***

* Level of difficulty
recode m3q0 (1 = 0) (2 = 1), gen(g1_difficult_before)
lab var g1_difficult_before "Chose difficult in game 1 (before playing)"
lab val g1_difficult_before game_difficulty

* Time take, answer, correct answer and asking for solution
clonevar g1_r1_answer=m3q1_a
clonevar g1_r2_answer=m3q2_a
clonevar g1_r1_time=m3q1_b
clonevar g1_r2_time=m3q2_b
recode m3q1_c m3q2_c (2 = 0) (3 = .b), gen(g1_r1_correct g1_r2_correct)
recode m3q1_d m3q2_d (2 = 0), gen(g1_r1_askedsolution g1_r2_askedsolution)
forvalues i=1/4 {
	local j=`i'+2
	recode i_`i'_m3q3_a (1 = 0) (2 = 1), gen(g1_r`j'_difficult)
	clonevar g1_r`j'_answer=i_`i'_m3q3_b
	clonevar g1_r`j'_time=i_`i'_m3q3_c
	recode i_`i'_m3q3_d (2 = 0) (3 = .b), gen(g1_r`j'_correct)
	recode i_`i'_m3q3_e (2 = 0), gen(g1_r`j'_askedsolution)
}
recode m3q3_f (2= 0), gen(g1_completed)
clonevar g1_quit_round=m3q3_f_other

* Assign labels to variables for rounds 1-6
forvalues i=1/6 {
	lab var g1_r`i'_difficult "Chose difficult in game 1 round `i'"
	lab var g1_r`i'_time "Time for game 1 round `i'"
	lab var g1_r`i'_answer "Answer to game 1 round `i'"
	lab var g1_r`i'_correct "Correct answer to game 1 round `i'"
	lab var g1_r`i'_askedsolution "Asked solution of game 1 round `i'"
}
lab var g1_completed "Completed game 1"
lab var g1_quit_round "Round where game 1 was quit"
lab val g1_r?_difficult game_difficulty
lab val g1_r?_correct game_correct
lab val g1_r?_askedsolution g1_completed yn
lab val g1_r?_answer dk

* Level of difficulty for next interview
recode m3q4_a (1 98 = 0) (2 = 1) (99 = .a), gen(g1_difficult_nextwave)
lab var g1_difficult_nextwave "Chose difficult for next wave"


* Correction for when Game 1 was quit
assert g1_completed==0 if !missing(g1_quit_round)
forvalues i=1/6 {
	dis "Looking at round `i'"
	assert g1_r`i'_answer==-1 if g1_quit_round<=`i'
	replace g1_r`i'_answer=.b if g1_r`i'_answer==-1 & g1_quit_round<=`i'
	assert g1_r`i'_answer!=-1
	replace g1_r`i'_difficult=.b if g1_quit_round<=`i'
	replace g1_r`i'_time=.b if g1_quit_round<=`i'
}


*** Mod. 3: generate new variables ***

* Overtime
forvalues i=1/6 {
	gen g1_r`i'_overtime=(g1_r`i'_time>60) if !missing(g1_r`i'_time)
	lab var g1_r`i'_overtime "Went over time in game 1 round `i'"
}

* Choices for level of difficulty
gen g1_all_difficult=(g1_r3_difficult==1 & g1_r4_difficult==1 & g1_r5_difficult==1 & g1_r6_difficult==1) ///
	if !mi(g1_r3_difficult) & !mi(g1_r4_difficult) & !mi(g1_r5_difficult) & !mi(g1_r6_difficult)
egen g1_number_difficult=rowtotal(g1_r3_difficult g1_r4_difficult g1_r5_difficult g1_r6_difficult) ///
	if !mi(g1_r3_difficult) & !mi(g1_r4_difficult) & !mi(g1_r5_difficult) & !mi(g1_r6_difficult), missing
lab var g1_all_difficult "Chose difficult in all rounds of game 1"
lab var g1_number_difficult "Number of rounds choosing difficult in game 1"



****************
*** MODULE 4 ***
****************

*** Mod. 4: edit existing variables ***

* HH expenditures
clonevar total_hh_exp=m4q4_1
lab var total_hh_exp "Total hh expenditures"

* Reservation wage
recode m4q3 (99999999 = .a), gen(reservation_wage)
lab var reservation_wage "Reservation wage"
lab val reservation_wage dk

* Decision making in the HH
recode m4q5* (99 = .b), gen(dec_hh_exp dec_income dec_illness dec_invest dec_work)
lab var dec_hh_exp "Decisions on daily household expenses"
lab var dec_income "Decisions on how to use income"
lab var dec_illness "Decisions on what to do in case of illness"
lab var dec_invest "Decisions on investing in a business"
lab var dec_work "Decisions on wether to work in a business"
lab val dec_hh_exp dec_income dec_illness dec_invest dec_work decision_maker


*** Mod. 4: generate new variables ***

* Total HH expenditures
egen sum_hh_exp=rowtotal(m4q4_2-m4q4_8), missing
lab var sum_hh_exp "Sum of hh expenditures"

* Decision making
egen nonmiss_dec=rownonmiss(dec_hh_exp dec_income dec_illness dec_invest dec_work)
egen partic_dec=anycount(dec_hh_exp dec_income dec_illness dec_invest dec_work), values(1 3 5)
egen own_dec=anycount(dec_hh_exp dec_income dec_illness dec_invest dec_work), values(1)
gen partic_decisionmaking=partic_dec/nonmiss_dec
gen own_decisionmaking=own_dec/nonmiss_dec
lab var partic_decisionmaking "HH decisions with his/her participation"
lab var own_decisionmaking "HH decisions made by him/herself"
drop nonmiss_dec partic_dec own_dec



****************
*** MODULE 5 ***
****************

*** Mod. 5: edit existing variables ***

* Level of difficulty
recode m5q1_a m5q1_b (2 = 0), gen(g2_difficult_before g2_difficult_after)
lab var g2_difficult_before "Chose difficult in game 2 (before seeing figure)"
lab var g2_difficult_after "Chose difficult in game 2 (after seeing figure)"
lab val g2_difficult_before g2_difficult_after game_difficulty

* Time taken
clonevar g2_time=m5q4
lab var g2_time "Time for game 2"

* Answer
recode m5q_answer (-1 = .b), gen(g2_answer)
lab var g2_answer "Answer to game 2"
lab val g2_answer dk

* Correct answer
recode m5q6 (2 = 0) (3 = .b), gen(g2_correct)
lab var g2_correct "Correct answer to game 2"
lab val g2_correct game_correct


* Correction for when Game 5 was quit
replace g2_difficult_before=.b if g2_correct==.b
replace g2_difficult_after=.b if g2_correct==.b
replace g2_time=.b if g2_correct==.b


*** Mod. 5: generate new variables ***

* Overtime
gen g2_overtime=(g2_time>120) if !missing(g2_time)
lab var g2_overtime "Went over time in game 2"
lab val g2_overtime yn

* Completed game 2
gen g2_completed=(m5q6!=3) if !missing(m5q6)
lab var g2_completed "Completed game 2"
lab val g2_completed yn



****************
*** MODULE 6 ***
****************

*** Mod. 6: edit existing variables ***

*** Mod. 6: generate new variables ***

* Compute number of solutions to barriers
egen barrier_first_appearing=rownonmiss(m6q2_other i_1_m6q3_other i_2_m6q3_other i_3_m6q3_other i_4_m6q3_other) if d1q2==1, strok
egen barrier_second_appearing=rownonmiss(m6q6_other i_1_m6q7_other i_2_m6q7_other i_3_m6q7_other i_4_m6q7_other) if d1q2==1, strok
gen barrier1_solutions=barrier_first_appearing if m6q1==1
gen barrier2_solutions=barrier_second_appearing if m6q1==1
replace barrier1_solutions=barrier_second_appearing if m6q1==2
replace barrier2_solutions=barrier_first_appearing if m6q1==2
lab var barrier1_solutions "N. of solutions to barrier 1"
lab var barrier2_solutions "N. of solutions to barrier 2"
drop barrier_first_appearing barrier_second_appearing

* Compute average number of solutions to barriers
egen barriers_solutions_avg=rowmean(barrier1_solutions barrier2_solutions)
lab var barriers_solutions_avg "Avg. n. of solutions to barriers"

* Reverse some items of the Likert scales
foreach var of varlist m6q10_a_1 m6q10_a_3 m6q10_a_5 m6q10_a_6 m6q10_a_8 m6q10_a_9 m6q10_a_19 ///
		m6q10_b_2 m6q10_b_4 m6q10_b_6 m6q10_b_8 m6q10_b_10 m6q12_1-m6q12_4 {
	gen rev_`var'=6-`var'
	lab var rev_`var' "`var' (reversed)"
}

* Big Five Personality Traits and other indexes from Likert scales
egen neuroticism=rowmean(m6q10_a_4 rev_m6q10_a_9 m6q10_a_14)
egen extraversion=rowmean(rev_m6q10_a_1 rev_m6q10_a_6 m6q10_a_11 m6q10_a_16 rev_m6q10_a_19)
egen opennness=rowmean(m6q10_a_2 m6q10_a_7 m6q10_a_12 m6q10_a_17 m6q10_a_20)
egen agreeableness=rowmean(rev_m6q10_a_5 m6q10_a_10 m6q10_a_15)
egen conscientiousness=rowmean(rev_m6q10_a_3 rev_m6q10_a_8 m6q10_a_13 m6q10_a_18 m6q10_a_21)
egen metacognition=rowmean(m6q9_1 m6q9_2 m6q9_3 m6q9_4)
egen need_cognition=rowmean(m6q9_5 m6q9_6 m6q9_7 m6q9_8)
egen entrep_greed=rowmean(m6q9_9 m6q9_10 m6q9_11 m6q9_12)
egen passion=rowmean(m6q9_13 m6q9_14 m6q9_15 m6q9_16 m6q9_17)
egen diligence=rowmean(m6q10_b_1 rev_m6q10_b_2 m6q10_b_3 rev_m6q10_b_4 m6q10_b_5 rev_m6q10_b_6 m6q10_b_7 rev_m6q10_b_8 m6q10_b_9 rev_m6q10_b_10)
egen grit=rowmean(rev_m6q12_1 rev_m6q12_2 rev_m6q12_3 rev_m6q12_4 m6q12_5 m6q12_6 m6q12_7 m6q12_8)
egen future_orient=rowmean(m6q13_1 m6q13_2 m6q13_3 m6q13_4 m6q13_5 m6q13_6 m6q13_7)
egen perseverance_aps=rowmean(m6q13_8 m6q13_9 m6q13_10 m6q13_11 m6q13_12)
egen perseverance=rowmean(m6q14_8 m6q14_9 m6q14_10 m6q14_11 m6q14_12 m6q14_13)
egen personal_initiative=rowmean(m6q14_1 m6q14_2 m6q14_3 m6q14_4 m6q14_5 m6q14_6 m6q14_7)
lab var neuroticism "Neuroticism"
lab var extraversion "Extraversion"
lab var opennness "Opennness to experience"
lab var agreeableness "Agreeableness"
lab var conscientiousness "Conscientiousness"
lab var metacognition "Metacognition"
lab var need_cognition "Need for cognition"
lab var entrep_greed "Entrepreneurial greed"
lab var passion "Passion"
lab var diligence "Diligence"
lab var grit "Grit"
lab var future_orient "Future orientation"
lab var perseverance_aps "Perseverance (Action Principles Scale)"
lab var perseverance "Perseverance"
lab var personal_initiative "Personal initiative"


****************
*** MODULE 7 ***
****************

*** Mod. 7: edit existing variables ***

* Course
recode m7q1 (2 = 0), gen(took_course)
lab var took_course "Took business course/seminar"
lab val took_course yn

* Month last course
recode m7q2_a (99 = .a), gen(month_course)
lab var month_course "Last month of business course"
lab val month_course months


****************
*** MODULE 8 ***
****************

*** Mod. 8: edit existing variables ***

*** Mod. 8: generate new variables ***

* Payoffs for each round
forvalues i=1/6 {
	gen g1_r`i'_payoff=0 if !missing(g1_r`i'_correct)
	replace g1_r`i'_payoff=500 if g1_r`i'_difficult==0 & g1_r`i'_correct==1
	replace g1_r`i'_payoff=2000 if g1_r`i'_difficult==1 & g1_r`i'_correct==1
	lab var g1_r`i'_payoff "Payoff for game 1 round `i'"
}
gen g2_payoff=0 if !missing(g2_correct)
replace g2_payoff=1000 if g2_difficult_after==0 & g2_correct==1
replace g2_payoff=2000 if g2_difficult_after==1 & g2_correct==1
lab var g2_payoff "Payoff for game 2"

* Expected payoff
gen expected_payoff=0 if d1q2==1
forvalues i=1/6 {
	replace expected_payoff=expected_payoff+500*(1/2/6) if g1_r`i'_difficult==0 & g1_r`i'_correct==1
	replace expected_payoff=expected_payoff+2000*(1/2/6) if g1_r`i'_difficult==1 & g1_r`i'_correct==1
}
replace expected_payoff=expected_payoff+1000*(1/2) if g2_difficult_after==0 & g2_correct==1
replace expected_payoff=expected_payoff+2000*(1/2) if g2_difficult_after==1 & g2_correct==1
lab var expected_payoff "Expected value of games payoff"
note expected_payoff: The expected value of the money that a respondent will receive with the random draw at the end of the survey ///
	taking into account that each round of game 1 has 1/12 probability to be picked and game 2 has 1/2 probability to be picked

* Total payoff
gen cumul_payoff=0 if d1q2==1
forvalues i=1/6 {
	replace cumul_payoff=cumul_payoff+500 if g1_r`i'_difficult==0 & g1_r`i'_correct==1
	replace cumul_payoff=cumul_payoff+2000 if g1_r`i'_difficult==1 & g1_r`i'_correct==1
}
replace cumul_payoff=cumul_payoff+1000 if g2_difficult_after==0 & g2_correct==1
replace cumul_payoff=cumul_payoff+2000 if g2_difficult_after==1 & g2_correct==1
lab var cumul_payoff "Cumulative payoff for games"
note cumul_payoff: The total payoff that a respondent would have received for the games if ALL rounds were rewarded in cash, ///
	instead of having the random draw at the end of the survey



**********************************
*** Variables for the analysis ***
**********************************

*** Edit variables for respondents without business ***

* Set variables to 0 for those without a business (accounting also for attriters for whom we have info)
foreach var of varlist register_bus sales_lastm sales_lastw profits_lastm profits_lastw profits_bestm corr_profits_lastm corr_profits_bestm pos_profits_* ///
		costs_lastm sum_costs investment investment_amount hours_worked sum_assets stock_value busprac_* rev_busprac_10 set_goal goal_quality goal_horizon ///
		total_employees employees_fulltime employees_parttime employees_paid employees_unpaid emp_evaluation emp_feedback hours_worked business_hours ///
		loan_requested loan_approved new_prod_svc total_new_prod_svc new_prod_svc_invented new_prod_svc_newtoregion has_ideas_business total_ideas_business ///
		purchased_bulk shared_inputs met_discuss_busideas new_activity {
	replace `var'=0 if has_business==0
}

* Replace month of interview with month of call for attriters without a business (to keep in regressions)
replace month_interview=month_call if missing(month_interview) & !missing(has_business)


*** Edit variables for attriters who answered to the sensitizers ***

* Generate dummy for attriters with sales and profits data
gen attriter_withdata=(profits_lastm==. & !missing(profits_lastm_attrit)) | (sales_lastm==. & !missing(sales_lastm_attrit))
lab var attriter_withdata "Attriter for whom there is data on sales and profits (from call)"
lab val attriter_withdata yn

* Replace sales and profits for attriters with sales and profits data
replace profits_lastm=profits_lastm_attrit if attriter_withdata==1
replace corr_profits_lastm=profits_lastm_attrit if attriter_withdata==1
replace sales_lastm=sales_lastm_attrit if attriter_withdata==1
replace month_interview=month_call if attriter_withdata==1


*** Transform variables ***

* Winsorize variables (only top 99%)
foreach var of varlist sales_lastm sales_lastw costs_lastm sum_costs investment_amount sum_assets stock_value {
	clonevar win_`var'=`var'
	summ `var' if selfemp==1, de
	replace win_`var'=r(p99) if win_`var'>r(p99) & !mi(win_`var')
	lab var win_`var' "Winsorized `= strlower("`: var lab `var''")'"
}

* Winsorize variables (bottom 1% and top 99%)
foreach var of varlist profits_lastm profits_lastw profits_bestm corr_profits_lastm corr_profits_bestm totalprofits_lastm othprofits_lastm {
	clonevar win_`var'=`var'
	summ `var' if selfemp==1, de
	replace win_`var'=r(p1) if win_`var'<r(p1) & !mi(win_`var')
	replace win_`var'=r(p99) if win_`var'>r(p99) & !mi(win_`var')
	lab var win_`var' "Winsorized `= strlower("`: var lab `var''")'"
}

* Winsorize variables (only top 95%)
foreach var of varlist sales_lastm hours_worked {
	clonevar win5_`var'=`var'
	summ `var' if selfemp==1, de
	replace win5_`var'=r(p95) if win5_`var'>r(p95) & !mi(win5_`var')
	lab var win5_`var' "Winsorized (5%) `= strlower("`: var lab `var''")'"
}

* Winsorize variables (bottom 5% and top 95%)
foreach var of varlist profits_lastm corr_profits_lastm corr_profits_bestm {
	clonevar win5_`var'=`var'
	summ `var' if selfemp==1, de
	replace win5_`var'=r(p5) if win5_`var'<r(p5) & !mi(win5_`var')
	replace win5_`var'=r(p95) if win5_`var'>r(p95) & !mi(win5_`var')
	lab var win5_`var' "Winsorized (5%) `= strlower("`: var lab `var''")'"
}

* Transform monetary variables variables with inverse hypebolic sine (IHS)
foreach var of varlist sales_lastm sales_lastw profits_lastm profits_lastw profits_bestm corr_profits_lastm corr_profits_bestm {
	gen ihs_`var'=ln(`var'+sqrt(`var'^2+1))
	lab var ihs_`var' "IHS of `= strlower("`: var lab `var''")'"
}

* Recode sales and profits variables to 0 for those who don't have a business (what about log-transformed variables?)
foreach var of varlist sales_lastm sales_lastw win_sales_lastm ihs_sales_lastm profits_lastm profits_lastw profits_bestm corr_profits_lastm corr_profits_bestm ///
		win_profits_lastm ihs_profits_lastm win_profits_lastw ihs_profits_lastw win_profits_bestm ihs_profits_bestm {
	replace `var'=0 if selfemp==0
}


*** Create sales and profits index ***

* Compute z-scores
foreach var of varlist sales_lastm win_sales_lastm ihs_sales_lastm profits_lastm win_profits_lastm ihs_profits_lastm {
	summ `var' if treatment==0
	gen z_`var'=(`var'-r(mean))/r(sd)
	lab var z_`var' "Z-score: `: var lab `var''"
}

* Generate sales and profit index
egen sales_profits_index=rowmean(z_sales_lastm z_win_sales_lastm z_ihs_sales_lastm z_profits_lastm z_win_profits_lastm z_ihs_profits_lastm)
lab var sales_profits_index "Sales and profits index"

* Replace sales and profits index with missing if any component is missing
replace sales_profits_index=. if mi(sales_lastm) | mi(profits_lastm)

* Standardize sales and profits index
summ sales_profits_index if treatment==0
replace sales_profits_index=(sales_profits_index-r(mean))/r(sd)


*** Create capital and labor index ***

* Compute z-scores
foreach var of varlist total_employees employees_fulltime employees_parttime employees_paid employees_unpaid win5_hours_worked business_hours ///
		investment win_investment_amount win_sum_assets win_stock_value {
	summ `var' if treatment==0
	gen z_`var'=(`var'-r(mean))/r(sd)
	lab var z_`var' "Z-score: `: var lab `var''"
}

* Generate capital and labor index (simplified)
egen inputs_index=rowmean(z_total_employees z_employees_fulltime z_employees_parttime z_investment z_win_investment_amount)
lab var inputs_index "Capital and labor inputs index (simple)"

* Generate capital and labor index (with more variables)
egen capital_labor_inputs_index=rowmean(z_win5_hours_worked z_business_hours z_total_employees z_employees_paid z_employees_unpaid ///
	z_win_sum_assets z_win_stock_value z_investment z_win_investment_amount)
replace capital_labor_inputs_index=0 if has_business==0
lab var capital_labor_inputs_index "Capital and labor inputs index"


*** Create business practices indexes ***

* Generate business practices score as total of business practices adopted (i.e. going 0-7)
egen business_practices=rowtotal(busprac_3 busprac_6 busprac_8 busprac_9 busprac_15 busprac_12 busprac_20), missing
replace business_practices=0 if has_business==0
lab var business_practices "Business practice score"

* Generate business practices score as total of business practices adopted for longer list in fu2 (i.e. going 0-24)
egen all_business_practices=rowtotal(busprac_1-busprac_9 rev_busprac_10 busprac_11-busprac_25), missing
replace all_business_practices=0 if has_business==0
lab var all_business_practices "All business practices score"

* Generate business practices index as share of business practices adopted (i.e. going 0-1)
egen business_practices_index=rowmean(busprac_3 busprac_6 busprac_8 busprac_9 busprac_15 busprac_12 busprac_20)
replace business_practices_index=0 if has_business==0
lab var business_practices_index "Business practices index"

* Generate business practices index as share of business practices adopted for longer list in fu2 (i.e. going 0-1)
egen all_business_practices_index=rowmean(busprac_1-busprac_9 rev_busprac_10 busprac_11-busprac_25)
replace all_business_practices_index=0 if has_business==0
lab var all_business_practices_index "All business practices index"

* Generate marketing and customer service practices index
egen marketing_index=rowmean(busprac_3 busprac_4 busprac_6 busprac_7)
replace marketing_index=0 if has_business==0
lab var marketing_index "Marketing and customer service practices"

* Generate accounting practices index
egen count_finstat=rowtotal(busprac_22 busprac_23 busprac_24 busprac_25), missing
gen prepares_all_finstat=(count_finstat==4) if !missing(count_finstat)
lab var prepares_all_finstat "Prepares all financial statements"
drop count_finstat
egen accounting_index=rowmean(busprac_11 busprac_12 busprac_13 busprac_14 busprac_17 busprac_18 busprac_21 prepares_all_finstat)
replace accounting_index=0 if has_business==0
lab var accounting_index "Accounting and financial management practices"

* Generate operations and performance management practices index
egen operat_perform_index=rowmean(busprac_8 rev_busprac_10 busprac_15 busprac_16 busprac_19 busprac_20)
replace operat_perform_index=0 if has_business==0
lab var operat_perform_index "Operations and performance management practices"

* Generate information and opportunity seeking practices index
egen info_opportunity_index=rowmean(busprac_1 busprac_2 busprac_5 busprac_9 met_discuss_busideas)
replace info_opportunity_index=0 if has_business==0
lab var info_opportunity_index "Information and opportunity seeking practices"

* Generate human resource management practices index
egen hr_index=rowmean(emp_evaluation emp_feedback)
replace hr_index=0 if has_business==0
lab var hr_index "Human resource management practices"


*** Create innovation index ***

* Compute z-scores
foreach var of varlist new_prod_svc total_new_prod_svc new_prod_svc_invented new_prod_svc_newtoregion has_ideas_business total_ideas_business {
	summ `var' if treatment==0
	gen z_`var'=(`var'-r(mean))/r(sd)
	lab var z_`var' "Z-score: `: var lab `var''"
}

* Generate innovation index
egen innovation_index=rowmean(z_new_prod_svc z_total_new_prod_svc z_new_prod_svc_invented z_new_prod_svc_newtoregion ///
	z_has_ideas_business z_total_ideas_business)
lab var innovation_index "Innovation index"


*** Create networking index ***

* Compute z-scores
foreach var of varlist purchased_bulk shared_inputs met_discuss_busideas {
	summ `var' if treatment==0
	gen z_`var'=(`var'-r(mean))/r(sd)
	lab var z_`var' "Z-score: `: var lab `var''"
}

* Generate networking index
egen networking_index=rowmean(z_purchased_bulk z_shared_inputs z_met_discuss_busideas)
lab var networking_index "Networking index"


*** Create indexes for personality traits (from Likert scales) ***

* Compute z-scores
foreach var of varlist m6q9* m6q10* m6q12* m6q13* m6q14* rev_m6* {
	summ `var' if treatment==0
	gen z_`var'=(`var'-r(mean))/r(sd)
	lab var z_`var' "Z-score: `: var lab `var''"
}

* Generate (UNstandardized!) personality indexes (standardized below!)
egen neuroticism_index=rowmean(z_m6q10_a_4 z_rev_m6q10_a_9 z_m6q10_a_14)
egen extraversion_index=rowmean(z_rev_m6q10_a_1 z_rev_m6q10_a_6 z_m6q10_a_11 z_m6q10_a_16 z_rev_m6q10_a_19)
egen opennness_index=rowmean(z_m6q10_a_2 z_m6q10_a_7 z_m6q10_a_12 z_m6q10_a_17 z_m6q10_a_20)
egen agreeableness_index=rowmean(z_rev_m6q10_a_5 z_m6q10_a_10 z_m6q10_a_15)
egen conscientiousness_index=rowmean(z_rev_m6q10_a_3 z_rev_m6q10_a_8 z_m6q10_a_13 z_m6q10_a_18 z_m6q10_a_21)
egen metacognition_index=rowmean(z_m6q9_1 z_m6q9_2 z_m6q9_3 z_m6q9_4)
egen need_cognition_index=rowmean(z_m6q9_5 z_m6q9_6 z_m6q9_7 z_m6q9_8)
egen entrep_greed_index=rowmean(z_m6q9_9 z_m6q9_10 z_m6q9_11 z_m6q9_12)
egen passion_index=rowmean(z_m6q9_13 z_m6q9_14 z_m6q9_15 z_m6q9_16 z_m6q9_17)
egen diligence_index=rowmean(z_m6q10_b_1 z_rev_m6q10_b_2 z_m6q10_b_3 z_rev_m6q10_b_4 z_m6q10_b_5 z_rev_m6q10_b_6 z_m6q10_b_7 z_rev_m6q10_b_8 z_m6q10_b_9 z_rev_m6q10_b_10)
egen grit_index=rowmean(z_rev_m6q12_1 z_rev_m6q12_2 z_rev_m6q12_3 z_rev_m6q12_4 z_m6q12_5 z_m6q12_6 z_m6q12_7 z_m6q12_8)
egen future_orient_index=rowmean(z_m6q13_1 z_m6q13_2 z_m6q13_3 z_m6q13_4 z_m6q13_5 z_m6q13_6 z_m6q13_7)
egen perseverance_aps_index=rowmean(z_m6q13_8 z_m6q13_9 z_m6q13_10 z_m6q13_11 z_m6q13_12)
egen perseverance_index=rowmean(z_m6q14_8 z_m6q14_9 z_m6q14_10 z_m6q14_11 z_m6q14_12 z_m6q14_13)
egen personal_initiative_index=rowmean(z_m6q14_1 z_m6q14_2 z_m6q14_3 z_m6q14_4 z_m6q14_5 z_m6q14_6 z_m6q14_7)
lab var neuroticism_index "Neuroticism index"
lab var extraversion_index "Extraversion index"
lab var opennness_index "Opennness to experience index"
lab var agreeableness_index "Agreeableness index"
lab var conscientiousness_index "Conscientiousness index"
lab var metacognition_index "Metacognition index"
lab var need_cognition_index "Need for cognition index"
lab var entrep_greed_index "Entrepreneurial greed index"
lab var passion_index "Passion index"
lab var diligence_index "Diligence index"
lab var grit_index "Grit index"
lab var future_orient_index "Future orientation index"
lab var perseverance_aps_index "Perseverance (Action Principles Scale) index"
lab var perseverance_index "Perseverance index"
lab var personal_initiative_index "Personal initiative index"

* Standardize personality indexes
foreach var of varlist neuroticism_index extraversion_index opennness_index agreeableness_index conscientiousness_index metacognition_index ///
		need_cognition_index entrep_greed_index passion_index diligence_index grit_index future_orient_index perseverance_aps_index perseverance_index ///
		personal_initiative_index {
	summ `var' if treatment==0
	replace `var'=(`var'-r(mean))/r(sd)
}


*** Create index for barriers ***

* Standardize barriers solutions
summ barriers_solutions_avg if treatment==0
gen barriers_index=(barriers_solutions_avg-r(mean))/r(sd)
lab var barriers_index "Barriers index"

* Generate soft skills index
egen softskills_index=rowmean(grit_index perseverance_aps_index perseverance_index personal_initiative_index future_orient_index barriers_index)
lab var softskills_index "Soft skills index"


*** Create index for other personality traits ***

* Generate personality index
egen personality_index=rowmean(metacognition_index need_cognition_index entrep_greed_index passion_index)
lab var personality_index "Other personality traits index"


*** Create index for difficult task in Game 1 ***

* Compute z-scores
foreach var of varlist g1_r3_difficult g1_r4_difficult g1_r5_difficult g1_r6_difficult g1_all_difficult g1_number_difficult g1_difficult_nextwave {
	summ `var' if treatment==0
	gen z_`var'=(`var'-r(mean))/r(sd)
	lab var z_`var' "Z-score: `: var lab `var''"
}

* Generate difficult task index
egen g1_difficult_index=rowmean(z_g1_r3_difficult z_g1_r4_difficult z_g1_r5_difficult z_g1_r6_difficult z_g1_all_difficult ///
	z_g1_number_difficult z_g1_difficult_nextwave)
lab var g1_difficult_index "Difficult task index"

* Replace difficult task index with missing if any component is missing
egen hasmiss=rowmiss(g1_r3_difficult g1_r4_difficult g1_r5_difficult g1_r6_difficult g1_all_difficult g1_number_difficult g1_difficult_nextwave)
replace g1_difficult_index=. if hasmiss>0
drop hasmiss

* Standardize difficult task index
summ g1_difficult_index if treatment==0
replace g1_difficult_index=(g1_difficult_index-r(mean))/r(sd)


*** Generate additional variables ***

* Generate innovation variable
clonevar innovation=new_prod_svc
lab var innovation "Introduced innovation"



**************
*** Saving ***
**************

* Save dataset
compress
save "$data_fin/fu2_data_final", replace


